<?php
header("Content-type:text/html;charset=utf-8;");
include 'conn/conn.php';
include "plugins/ckeditor/ckeditor.php";
include "plugins/ckfinder/ckfinder.php";
     
$CKEditor = new CKEditor();
$CKEditor->returnOutput = true;
$CKEditor->basePath = 'plugins/ckeditor/';              
//$CKEditor->config['width'] = 1000;                    
$CKEditor->config['height'] = 400;                    
$config['skin'] = 'kama';
 
$cid=$_GET["id"];
$sql=mysql_query("select * from tb_plugin where id=$cid");
$row = mysql_fetch_array($sql);

CKFinder::SetupCKEditor($CKEditor, 'plugins/ckfinder/') ;//注意这里是相对路径，相对于根目录，不能用绝对路径
$value = $row["content"]; 
$contentarea = $CKEditor->editor("content",$value,$config);//生成一个以name为content的textarea



if (isset($_POST["into_content"])){
	$name = $_POST['name'];
	$content = $_POST['content'];
	$id = $_POST['id'];
	$date = date("Y-m-d");
	$sql = "update tb_plugin set name='$name',content='$content',uptime='$date' where id=$id";
	if (mysql_query($sql)){
		echo ("<script type=\"text/javascript\">alert('修改成功！');window.location.href='plugin_manage.php';</script>");
		exit();
	}else {
		echo("<script language='javascript'>alert('失败，请联系管理员！');history.back();</script>");
		exit();
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Ajax File Manager</title>
	<link rel="stylesheet" href="templets/css/common.css" type="text/css" />
	<meta http-equiv="Content-type" content="text/html; charset=utf8" />
</head>
<body>
<div id="man_zone">
	<form action="" method="post">
		<table width="99%" border="0" align="center"  cellpadding="1" cellspacing="0" class="table_style">
    		<tr>
      			<td width="18%" class="left_title_1 nos"><span class="left-title">插件名称：</span></td>
      			<td width="82%" class="nos"><input type="text" name="name" value="<?php echo ($row["name"]);?>" /></td>
    		</tr>
    		<tr>
      			<td class="left_title_2 nos">插件代码：</td>
      			<td class="nos"><?php echo $contentarea;?></td>
    		</tr>
    		<tr>
				<td colspan="2" align="right" class="nos">
					<input type="submit" name="into_content" value="提交" />
					<input type="reset" value="重置" />
					<input type="hidden" name="id" value="<?php echo ($row["id"])?>" />
				</td>
			</tr>
		</table>
	</form>
</div>
</body>
</html>